<?php

namespace Common\Model;

/**
 * VipInfoModel.class.php实例模型
 *
 * @author zhangzhen
 * @date 2017-2-15
 */
class VipInfoModel extends BaseModel {

    protected $trueTableName = 'tb_vip_info';

    /**
     * 返回会员设置数据
     * @modify zhangzhen 2017-02-15    获取掌柜的会员设置信息
     * @param integer $hotelId 客栈ID
     * @return type
     */
    public function getInfoByHotel($hotelId) {
        $option = [
            'hotelentity_id'=> $hotelId,
        ];
        $field = 'id,hotelentity_id,name,auto,levelrule,discountrule';
        $data = $this->field($field)->where($option)->select();

        return empty($data) ? array() : $data;
    }

    /**
     * 返回会员设置数据
     * @modify zhangzhen 2017-02-15    获取掌柜的会员设置信息
     * @param integer $hotelId 客栈ID
     * @return type
     */
    public function getInfoById($id) {
        $option = [
            'id'=> $id,
        ];
        $field = 'id,hotelentity_id,name,auto,level,levelrule,discount,discountrule';
        $data = $this->field($field)->where($option)->find();

        return empty($data) ? array() : $data;
    }
}
